#include <stdio.h>
#include <stdlib.h>
#include "ask_mpeg_encode.h"
#include "format.h"
#include "utils.h"


int main(int argc,char **argv)
{
	if(argc!=3)
	{
		fprintf(stderr,"Usage: %s input.dat output.mpg\n",argv[0]);
		exit(1);
	}

	FILE *in=open_file(argv[1],"rb",stdin,"Couldn't open file \"%s\".\n");

	fseek(in,0,SEEK_END);
	int length=ftell(in);
	fseek(in,0,SEEK_SET);

	u_int8_t bytes[length];
	fread(bytes,1,length,in);
	if(in!=stdin) fclose(in);

	check_errors(bytes,length,argv[1],1);

	FILE *out=open_file(argv[2],"wb",stdout,"Couldn't create file \"%s\".\n");
	write_ask_mpeg_to_file(out,bytes,file_size(bytes,length));
	if(out!=stdout) fclose(out);
}
